package functions 
{	import functions.FunctionNode;	/**
	 * @author admin
	 */
	public class IfFunctionNode extends FunctionNode 
	{
		public function IfFunctionNode()
		{
			funcname = "if";	
			functiontype = SPECIALFUNCTION;
		}
		
		override public function getValue( args : XML, scope : Object ) : XML
		{
			
			var returnXML:XML;
			
			// let's evaluate the predicate. it should return <t/> or <list/>.
			
			var t_or_f:XML = Evaluator.evaluate(args.children()[ 0 ], scope);
			
			
			if( Evaluator.isTrue( t_or_f ) )
			{
				returnXML = Evaluator.evaluate(args.children()[ 1 ], scope);
			}
			else
			{
				returnXML = Evaluator.evaluate(args.children()[ 2 ], scope);
			}
			
			return returnXML;
		}	}}